# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/9/16
# @File : 4.Money Sums.py

modulo = 10 ** 9 + 7

def dp_solve1():
    total = sum(rate)
    dp = [False] * (total + 1)
    dp[0] = True
    cnt = 0
    for i in range(1, n + 1):
        for j in range(total, rate[i] - 1, -1):  # 一维数组的话必须倒序
            dp[j] = dp[j] or dp[j - rate[i]]

    #打印结果部分
    for i in range(1, total + 1):
        if (dp[i]):
            cnt += 1
    print(cnt)
    for i in range(1, total + 1):
        if (dp[i]):
            print(i, end=" ")

def dp_solve():
    bitset = 1
    total = 0
    cnt = 0
    for i in range(n + 1):
        bitset |= bitset << rate[i]
        total += rate[i]

    dp = bin(bitset)[2:]
    for i in range(1, total + 1):
        if (dp[i]=='1'):
            cnt += 1
    print(cnt)
    for i in range(1, total + 1):
        if (dp[i]=='1'):
            print(i, end=" ")

"""
参考子集和问题。Cooking

"""
if __name__ == '__main__':
    n = int(input())
    rate = [int(i) for i in input().split()]
    rate = [0] + rate
    dp_solve()

